package com.nbufe.controller;

import com.nbufe.domain.ResponseResult;
import com.nbufe.domain.dto.predict.ModelDto;
import com.nbufe.domain.dto.target.AddTargetDto;
import com.nbufe.domain.dto.target.EditTargetDto;
import com.nbufe.domain.dto.target.QueryEmissionTargetDto;
import com.nbufe.domain.dto.target.QueryTargetPageDto;
import com.nbufe.domain.vo.predict.PredictDataVo;
import com.nbufe.service.CarbonEmissionPredictService;
import com.nbufe.service.CarbonTargetService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;

/**
 * 碳目标接口Api
 *
 * @Author luzhiheng
 * @Date 2023/12/24 17:42
 */
@RestController
@RequestMapping("/carbon_target")
public class CarbonPredictController {

    @Resource
    private CarbonEmissionPredictService carbonEmissionPredictService;

    @PostMapping("/predictFutureYearsCarbonEmission")
    public ResponseResult predictFutureYearsCarbonEmission(@Validated @RequestBody ModelDto dto) {
        Double[] data = new Double[dto.getData().size()];
        PredictDataVo predictDataVo = carbonEmissionPredictService.autoRegressionPrediction(dto.getData().toArray(data), dto.getOrder(), dto.getFutureYears());
        return ResponseResult.okResult(predictDataVo);
    }

}